from time import sleep
from threading import Thread

# 生成车票
tickets = ["T%d"%i for i in range(1,501)]

# 每个线程都卖票
def sell(w):
    while tickets:
        # 取出的就是票
        # val = tickets.pop(0)
        print("%s --- %s"%(w,tickets.pop(0)))
        sleep(0.1)

jobs = []
for i in range(1,11):
    t = Thread(target=sell,args=("W%d"%i,))
    jobs.append(t) # 存储线程对象
    t.start()

for i in jobs:
    i.join()
print("票已售罄")